﻿using Ozone.DAL;
using Ozone.Help;
using Ozone.Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ozone.BLL
{
    public class Sys_DictBLL
    {
        private static List<sys_dict> _allsys_dict;

        /// <summary>
        /// 添加字典信息
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public static bool AddDictInfo(sys_dict Model)
        {
            bool IsSuccess = false;
            try
            {
                IsSuccess = Sys_DictDAL.AddDictInfo(Model);
            }
            catch (Exception ex)
            {
                LogHelper.Error("添加字典信息异常", ex);
                IsSuccess = false;
            }
            LogHelper.Debug("添加字典信息异常");

            return IsSuccess;
        }

        /// <summary>
        /// 删除字典信息
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static bool DeleteDictInfo(string ID)
        {
            bool IsSuccess = false;
            try
            {
                SqlSugarScope db = SqlSugarOper.Instance.GetDbClient();
                if (!string.IsNullOrEmpty(ID))
                {
                    IsSuccess = Sys_DictDAL.DeleteDictInfo(ID);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("删除字典信异常", ex);
                IsSuccess = false;
            }
            return IsSuccess;
        }

        /// <summary>
        /// 修改字典信息
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public static bool UpdateDictInfo(sys_dict model)
        {
            bool IsSuccess = false;
            try
            {
                if (model != null)
                {
                    IsSuccess = Sys_DictDAL.UpdateDictInfo(model);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("修改字典信息异常", ex);
                IsSuccess = false;
            }
            return IsSuccess;
        }

        /// <summary>
        /// 查询用户信息
        /// </summary>
        /// <param name="ID">ID</param>
        /// <returns></returns>
        public static List<sys_dict> GetDictInfoList(string ID)
        {
            try
            {
                _allsys_dict = Sys_DictDAL.GetDictInfoList(ID);
            }
            catch (Exception ex)
            {
                LogHelper.Error("查询字典信息发生异常", ex);
                _allsys_dict = null;
            }
            return _allsys_dict;
        }
    }
}
